package org.ali.creationalpattern.singletonpattern.singletonobject;

/**
 * 双检锁，懒加载，线程安全，高性能
 */
public class SingletonObject4 {
    private static volatile SingletonObject4 object;

    private SingletonObject4() {
    }

    public static SingletonObject4 getInstance() {
        if (object == null) {
            synchronized (SingletonObject4.class) {
                if (object == null) {
                    object = new SingletonObject4();
                }
            }
        }

        return object;
    }

    public void showMessage() {
        System.out.println("双检锁，懒加载，线程安全，高性能");
    }
}
